package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import com.qsn.tool.common.base.PageForm;
import com.qsn.tool.common.base.PageData;
import com.github.pagehelper.PageHelper;
import com.qsn.tool.common.util.PageUtil;

import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
<#--import com.qsn.page.helper.configure.util.BeanConvertUtils;-->
import javax.annotation.Resource;
<#--import org.springframework.beans.factory.annotation.Autowired;-->

import java.util.List;


/**
 * ${table.comment!} 服务实现类
 *
 * @author ${author}
 * @date ${date}
 */
@Slf4j
@Service
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
public class ${table.serviceImplName} implements ${table.serviceName} {
    @Resource
    private  ${table.mapperName} ${table.mapperName?uncap_first};


    @Override
    public PageData<${table.entityName}> listPage${table.entityName}(PageForm<${table.entityName}> pageForm) {
        PageHelper.startPage(pageForm.getCurrentPage(), pageForm.getPageSize());
        List<${table.entityName}> ${table.entityName?uncap_first}List = ${table.mapperName?uncap_first}.listPage${table.entityName}(pageForm.getData());
        return PageUtil.setPageInfo(${table.entityName?uncap_first}List);
    }

    @Override
    public List<${table.entityName}> list${table.entityName}(${table.entityName} ${table.entityName?uncap_first}){
        return ${table.mapperName?uncap_first}.list${table.entityName}(${table.entityName?uncap_first});
    }

    @Override
    public boolean insert${table.entityName}(${table.entityName} ${table.entityName?uncap_first}){
        int insertNum = ${table.mapperName?uncap_first}.insert${table.entityName}(${table.entityName?uncap_first});
        return insertNum == 1 ? true : false;
    }

    @Override
    public boolean update${table.entityName}ById(${table.entityName} ${table.entityName?uncap_first}){
        int updateNum = ${table.mapperName?uncap_first}.update${table.entityName}ById(${table.entityName?uncap_first});
        return updateNum == 1 ? true : false;
    }

    @Override
    public ${table.entityName} get${table.entityName}ById(${table.entityName} ${table.entityName?uncap_first}){
        return ${table.mapperName?uncap_first}.get${table.entityName}ById(${table.entityName?uncap_first});
    }


}
</#if>
